# 封装断言
import json


def assert_common_util(self, response, status_code, success, code, message):
    self.assertEqual(status_code, response.status_code)
    self.assertEqual(success, response.json().get("success"))
    self.assertEqual(code, response.json().get("code"))
    self.assertIn(message, response.json().get("message"))


# 编写一个读取外部数据文件的函数  filename是文件的路径
def read_login_data(filename):
    with open(filename, mode="r", encoding="utf-8") as f:
        jsonData = json.load(f)
        temp_list = list()
        for login_data in jsonData:
            temp_list.append(tuple(login_data.values()))
    return temp_list


def read_emp_data(filename, type):
    with open(filename, mode="r", encoding="utf-8") as f:
        jsonData = json.load(f)
        # list' object has no attribute 'get'错误的原因是json文件中我外面加了个[],变成了列表，把[]删了就好了  或者是用for循环遍历也行
        emp_data = jsonData.get(type)
        temp_list = list()
        temp_list.append(tuple(emp_data.values()))
    return temp_list

#
# read_emp_data(app.BASE_DIR + "/data/employee.json", "add_emp")
